<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="" method="get">
        用户名：<input type="text" name="username">
        <br>
        密码：<input type="password" name="password">
        <br>
        年龄：<input type="text" name="age">
        <br>
        <br />
        <button type="submit">提交</button>
    </form>
    <script>
        var str = "http://127.0.0.1:5500/%E7%AC%AC%E4%BA%8C%E9%98%B6%E6%AE%B5/%E7%AC%AC%E4%BA%8C%E5%91%A8/day10/day10_new/Address2.html?username=asdhaj&password=123asf&age=15"

        // 法一：
        var arr = str.split("?")
        console.log(arr);

        var newarr = arr[1].split("&");
        console.log(newarr);

        var lastarr = []
        newarr.forEach(function (item, m) {
            lastarr.push(item.split("="));
        })

        console.log(lastarr);

        // 法二：
        // var newstr = str.split("?")[1];
        // var newarr = newstr.split("&");

        // 即等同
        var newarr2 = str.split("?")[1].split("&");
        console.log(newarr2);
        var lastarr2 = newarr.map(function (item, m) {
            return item.split("=");
        })

        console.log(lastarr2);
    </script>
</body>

</html>